#  cmake -DCMAKE_BUILD_TYPE=Debug ../../.
#  cmake -DCMAKE_BUILD_TYPE=Release ../../.
#  cmake -DCMAKE_BUILD_TYPE=Debug ../../. -G Xcode
#  cmake -DCMAKE_BUILD_TYPE=Release ../../. -G Xcode

SET(CMAKE_LEGACY_CYGWIN_WIN32 0)

project(HTML_TERMINAL_MASK)
cmake_minimum_required( VERSION 2.6 FATAL_ERROR )

SET(TARGET "htmlMask")
 
MESSAGE( "SCAN DE SISTEMA" )
MESSAGE( "==========================================================================" )
MESSAGE( STATUS "SISTEMA ACTUAL              : "${CMAKE_SYSTEM_NAME} )
MESSAGE( STATUS "MODO                        : "${CMAKE_BUILD_TYPE} )
MESSAGE( STATUS "CMAKE_COMPILER_IS_GNUCXX    : "${CMAKE_COMPILER_IS_GNUCXX} )
MESSAGE( STATUS "UNIX                        : "${UNIX} )
MESSAGE( STATUS "WIN32                       : "${WIN32} )
MESSAGE( STATUS "APPLE                       : "${APPLE} )
MESSAGE( STATUS "MINGW                       : "${MINGW} )
MESSAGE( STATUS "MSYS                        : "${MSYS} )
MESSAGE( STATUS "CYGWIN                      : "${CYGWIN} )
MESSAGE( STATUS "BORLAND                     : "${BORLAND} )
MESSAGE( STATUS "WATCOM                      : "${WATCOM} )
MESSAGE( "==========================================================================" )

add_executable(${TARGET} 	HtmlMask/main.cpp HtmlMask/webServer.cpp HtmlMask/htmlGui.cpp HtmlMask/XmlConfig.cpp
						 	HtmlMask/pugixml.cpp HtmlMask/configAttribs.cpp HtmlMask/mapAttribs.cpp HtmlMask/GuiConsts.cpp
						 	HtmlMask/Utils.cpp HtmlMask/MakeGui.cpp HtmlMask/createFileXml.cpp
						 	HtmlMask/GuiConsts.hpp
							HtmlMask/MakeGui.hpp
							HtmlMask/Utils.hpp
							HtmlMask/XmlConfig.hpp
							HtmlMask/configAttribs.hpp
							HtmlMask/createFileXml.hpp
							HtmlMask/htmlGui.hpp
							HtmlMask/main.hpp
							HtmlMask/mapAttribs.hpp
							HtmlMask/pugiconfig.hpp
							HtmlMask/pugixml.hpp
							HtmlMask/webServer.hpp
						 	)
						
        
  IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
	  MESSAGE( "SISTEMA: Apple OS X" )
	  MESSAGE( "==========================================================================" )	
	  IF(${CMAKE_BUILD_TYPE} MATCHES "Release")
		  MESSAGE( "Compilando en MODO RELEASE" )
		  add_definitions("-std=c++98 -DAPPLE -O3 -Wall -Wextra -pedantic -W -Wconversion -Wcast-qual -Wwrite-strings -Wstrict-aliasing  -Wpointer-arith -Wcast-align -fno-common") 
	  ELSE()
		  MESSAGE( "Compilando en MODO DEBUG" )
		  add_definitions("-std=c++98 -DAPPLE -O0 -Wall -Wextra -pedantic -W -Wconversion -Wcast-qual -Wwrite-strings -Wstrict-aliasing  -Wpointer-arith -Wcast-align -fno-common") 
	  ENDIF()        
	  FIND_PATH(MICROHTTPD_LIBRARY_INCLUDE_DIRECTORIES microhttpd.h "/opt/local/usr/include")
	  FIND_LIBRARY( MICROHTTPD_LIBRARY NAMES microhttpd libmicrohttpd PATHS /opt/local/lib)
	  include_directories ( ${MICROHTTPD_LIBRARY_INCLUDE_DIRECTORIES} )
	  link_directories ( ${MICROHTTPD_LIBRARY} )            
	  target_link_libraries ( ${TARGET} ${MICROHTTPD_LIBRARY}) 

  ELSE()
	  IF(${CYGWIN})  
		  MESSAGE( "SISTEMA: Cygwin/Windows" )
		  MESSAGE( "==========================================================================" )
		  IF(${CMAKE_BUILD_TYPE} MATCHES "Release")
			  MESSAGE( "Compilando en MODO RELEASE" )
			  add_definitions("-std=c++98 -DLINUX -O3 -Wall -Wextra -pedantic -W -Wconversion -Wcast-qual -Wwrite-strings -Wstrict-aliasing  -Wpointer-arith -Wcast-align -fno-common") 
		  ELSE()
			  MESSAGE( "Compilando en MODO DEBUG" )
			  add_definitions("-std=c++98 -DLINUX -O0 -Wall -Wextra -pedantic -W -Wconversion -Wcast-qual -Wwrite-strings -Wstrict-aliasing  -Wpointer-arith -Wcast-align -fno-common") 
		  ENDIF()
		  target_link_libraries(${TARGET} /usr/local/lib/libmicrohttpd.dll.a )
	  ELSE()
		  IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
			  MESSAGE( "SISTEMA: Linux" )
			  MESSAGE( "==========================================================================" )
			  IF(${CMAKE_BUILD_TYPE} MATCHES "Release")
				  MESSAGE( "Compilando en MODO RELEASE" )
				  add_definitions("-std=c++98 -DLINUX -O3 -Wall -Wextra -pedantic -W -Wconversion -Wcast-qual -Wwrite-strings -Wstrict-aliasing  -Wpointer-arith -Wcast-align -fno-common") 
			  ELSE()
				  MESSAGE( "Compilando en MODO DEBUG" )
				  add_definitions("-std=c++98 -DLINUX -O0 -Wall -Wextra -pedantic -W -Wconversion -Wcast-qual -Wwrite-strings -Wstrict-aliasing  -Wpointer-arith -Wcast-align -fno-common") 
			  ENDIF()                
			  FIND_PATH(MICROHTTPD_LIBRARY_INCLUDE_DIRECTORIES microhttpd.h "/usr/include")
			  FIND_LIBRARY( MICROHTTPD_LIBRARY NAMES microhttpd libmicrohttpd PATHS /usr/lib)
			  include_directories ( ${MICROHTTPD_LIBRARY_INCLUDE_DIRECTORIES} )
			  link_directories ( ${MICROHTTPD_LIBRARY} )            
			  target_link_libraries ( ${TARGET} ${MICROHTTPD_LIBRARY})                
		  ELSE()
			  MESSAGE( STATUS "ATENCION ALGO VA MAL !!! -> NO SE HA DETECTADO EL SISTEMA : " ${CMAKE_SYSTEM_NAME})
			  MESSAGE( "==========================================================================" )
		  ENDIF()
	  ENDIF()        
  ENDIF()
